package 第五天

/**
 * map的key 不能重复
 */
fun main() {
    val map = mapOf("中国" to "chinese", "美国" to "American")
//        println(map["中国"])

    //创建一个可读可写的集合
    val muMap = mutableMapOf("中国" to "chinese", "美国" to "American")
    muMap["日本"] = "Japan"
    muMap.put("英国","EG")
//    println(muMap)

    for (entry in muMap) {
//        println("key=${entry.key}  value=${entry.value}")
    }

    for ((k,v ) in muMap) {
//        println("key=$k  value=$v")
    }

//    println(muMap.keys) //获取map的key
//    println(muMap.values)

    //通过迭代器
    var interactor = muMap.iterator()
    while (interactor.hasNext()){
        val next = interactor.next()
        println(next.key)
    }
}
